<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<script src="${pageContext.request.contextPath}/js/printer.js" type="text/javascript"></script>
<style type="text/css">
    #agreementOuter {
    /*font-family: serif, arial, BhashitaComplex, Bhashitha2, Sri Tamil;*/
        font-size: 12pt;
        line-height: 2.0;
    }

    #agreementOuter p {
        font-size: 12pt;
        text-align: justify;
        line-height: 2.0;
    }

    #agreementOuter td {
        font-size: 12pt;
    }

    @media print {
        .bold-label-tag {
            font-weight: bold;
        }
    }
</style>

<script type="text/javascript">
    $(document).ready(function() {
        $('.land-table').dataTable({
            "sPaginationType": "two_button",
            "bShowAll": true
        });
    });

    $(function () {
        // initData();
        $('#cancelBtnId').val($('#cancelBtn').val());
        $('#printBtnId').val($('#printBtn').val());

    });


    function initData() {
        var id = $('select#gnDivisionId').attr('value');
        alert(id);
        var mode = "byGNDivision";
        var type = "preliminaryCandidatesList";
        $.getJSON('${pageContext.request.contextPath}/common/LandLookupService', {id:id, mode:mode, type:type}, function(data) {
            loadLandList(data.applicationList);
        });
    }


    function loadLandList(landInfo) {
        var opt = '';
        opt += '<thead>' +
                '<tr class="table-header">' +
                '<th class="center-align">' + $('#applied_date').val() + '</th>' +
                '<th class="center-align">' + $('#applicant_Name').val() + '</th>' +
                '<th class="left-align">' + $('#applicant_Address').val() + '</th>' +
                '</tr>' +
                '</thead>';
        opt += '<tbody>';
        if (landInfo.length > 0) {
            for (var i = 0; i < landInfo.length; i++) {
                opt += '<tr>' +
                        '<td class="center-align">' + landInfo[i].submitDate + '</td>' +
                        '<td class="center-align">' + landInfo[i].holderName + '</td>' +
                        '<td>' + landInfo[i].holderAddress + '</td>' +
                        '</tr>';
            }
            $('.print-btn').val($('#print').val());
            $('.print-btn').show();
            $('#report-header').show();
        }
        opt += '</tbody>';
        $('.land-table').html(opt);
    }
    /*$(document).ready(function() {
        $('.print-btn').hide();
        $('#report-header').hide();
        $('.print-btn').printPreview({

        });
    });*/



</script>

<%--<div>
    <table>
    <tr>
                <td><s:label value="%{getText('gn_division.label')}"/></td>
                <td><s:select id="gnDivisionId" name="gnDivisionId" list="gnDivisionList" headerKey="-1"
                              headerValue="%{getText('all.label')}" cssClass="width-200-px" multiple="true" /></td>

     <td><input type="button" id="select_all_col_managers" value="Add" onclick="initData()"/></td>

    </tr>


        </table>

    &lt;%&ndash;<s:select
                                name="dsDivisionName"
                                id="gnDivisionsSelected"
                                list="dsDi"
                                multiple="true"
                                />&ndash;%&gt;


</div>--%>

<div id="printbtn" class="form-button-div right-align">

    <input type="button" id="printBtnId" onclick="printPage('agreementOuter', 'A4', 'P');"/>
    <input class="printButton" type="button" id="cancelBtnId" onclick="goBack();">

</div>

<div id="agreementOuter">

    <div class="page-title">
        <h2><s:label value="%{getText('preliminarySelectionCandidatesList.label')}"/></h2>
    </div>

    <div id="report-header">
        <table class="width-100 margin-10-auto">
            <tr>
                <td><s:label value="%{getText('district.label')}"/> : <s:textfield id="district" name="districtName"
                                                                                   cssStyle="border:none; background: none; color: #000;"
                                                                                   disabled="true"/></td>
            </tr>
            <tr>
                <td><s:label value="%{getText('ds_division.label')}"/> : <s:textfield id="ds-name" name="dsDivisionName"
                                                                                      cssStyle="border:none; background: none; color: #000;"
                                                                                      disabled="true"/></td>
            </tr>

        </table>
    </div>


    <table class="width-100 margin-10-auto table land-table">
        <thead>
        <tr class="center-align table-header">
            <th><s:label value="%{getText('applied_date')}"/></th>
            <th><s:label value="%{getText('applicant_Name')}"/></th>
            <th><s:label value="%{getText('applicant_Address')}"/></th>
        </tr>
        </thead>
        <tbody>
        <s:iterator status="status1" value="landApplicationList">
            <tr class="<s:if test="#status1.odd == true">able-row-odd</s:if><s:else>table-row-even</s:else>t">
                <td class="center-align"><s:property value="submitDate"/></td>
                <td class="center-align"><s:property value="holder.name"/></td>
                <td class="center-align"><s:property value="holder.contacts.address"/></td>

            </tr>
        </s:iterator>
        </tbody>
    </table>


     <%--<div id="land-list">


            <table class="width-100 margin-10-auto table land-table" id="land-report-by-gn" border="1" cellpadding="0"
                   cellspacing="0">

            </table>

        </div>--%>



    <s:hidden id="printBtn" value="%{getText('print.label')}"/>
    <s:hidden id="cancelBtn" value="%{getText('back.label')}"/>

    <%--<s:hidden id="applied_date" value="%{getText('applied_date')}"/>
    <s:hidden id="applicant_Name" value="%{getText('applicant_Name')}"/>
    <s:hidden id="applicant_Address" value="%{getText('applicant_Address')}"/>--%>

</div>